/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <cstdio>
#include <cstring>
using namespace std;
const int L=257;
char first[L]= {0},next[L]= {0},longestCommonSuffix[L]= {0};
int main_1077()
{
    int N,firstLen,nextLen,n;
    scanf("%d",&N);
    getchar();
    scanf("%[^\n]",first);
    getchar();
    scanf("%[^\n]",next);
    getchar();
    firstLen=strlen(first);
    nextLen=strlen(next);
    n=(firstLen<nextLen)?firstLen:nextLen;
    for (int i=0; i<n ; ++i )
    {
        if (first[firstLen-i-1]!=next[nextLen-i-1])
        {
            break;
        }
        longestCommonSuffix[i]=first[firstLen-i-1];
    }
    for (int j=2; j<N ; ++j )
    {
        scanf("%[^\n]",next);
        getchar();
        firstLen=strlen(longestCommonSuffix);
        nextLen=strlen(next);
        n=(firstLen<nextLen)?firstLen:nextLen;
        for (int i=0; i<n ; ++i )
        {
            if (longestCommonSuffix[i]!=next[nextLen-i-1])
            {
                longestCommonSuffix[i]=0;
                break;
            }
        }
    }
    firstLen=strlen(longestCommonSuffix);
    if (firstLen==0)
    {
        printf("nai");
    }
    else
    {
        for (int i=firstLen-1; i>=0 ; --i )
        {
            printf("%c",longestCommonSuffix[i]);
        }
    }
    return 0;
}
